package com.zzc.common;


import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;


/**
 * @author zhouzhicheng
 * @version 1.0  2020/12/29
 */
@Data
@Builder
@AllArgsConstructor
public class JsonResult {
    private Boolean status;
    private String msg;
    private Object Result;

    /**
     * 返回成功状态 以及 数据
     * @param result
     * @return
     */
    public static JsonResult getResultSuccess(Object result){
        return new JsonResult(true,result);
    }

    /**
     * 返回成功状态
     * @return
     */
    public static JsonResult getResultSuccess(){
        return new JsonResult(true);
    }

    /**
     * 返回成功状态 、信息、以及数据
     * @param msg
     * @param result
     * @return
     */
    public static JsonResult getResultSuccess(String msg, Object result){
        return new JsonResult(true,msg,result);
    }

    /**
     * 返回成功状态以及信息
     * @param msg
     * @return
     */
    public static JsonResult getResultSuccess(String msg){
        return new JsonResult(true,msg);
    }

    /**
     * 返回失败状态
     * @return
     */
    public static JsonResult getResultFailed(){
        return new JsonResult(false);
    }

    /**
     * 返回失败状态以及信息
     * @param msg
     * @return
     */
    public static JsonResult getResultFailed(String msg){
        return new JsonResult(false,msg);
    }


    public JsonResult(Object result) {
        Result = result;
    }

    public JsonResult(String msg) {
        this.msg = msg;
    }

    public JsonResult(String msg, Object result) {
        this.msg = msg;
        Result = result;
    }

    public JsonResult(Boolean status, Object result) {
        this.status = status;
        Result = result;
    }

    public JsonResult(Boolean status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public JsonResult(Boolean status) {
        this.status = status;
    }
}
